package org.ourgrid.worker.business.requester;

import java.util.ArrayList;
import java.util.List;

import org.ourgrid.common.internal.IResponseTO;
import org.ourgrid.common.internal.RequesterIF;
import org.ourgrid.worker.business.dao.WorkerDAOFactory;
import org.ourgrid.worker.request.GetStatusRequestTO;
import org.ourgrid.worker.response.HereIsStatusResponseTO;

public class GetStatusRequester implements RequesterIF<GetStatusRequestTO> {

	public List<IResponseTO> execute(GetStatusRequestTO request) {
		List<IResponseTO> responses = new ArrayList<IResponseTO>();
		
		if (request.canStatusBeUsed()) {
			HereIsStatusResponseTO hereIsStatusResponseTO = new HereIsStatusResponseTO();
			hereIsStatusResponseTO.setClientAddress(request.getClientAddress());
			hereIsStatusResponseTO.setStatus(WorkerDAOFactory.getInstance().getWorkerStatusDAO().getStatus());
			
			responses.add(hereIsStatusResponseTO);
		}
		
		return responses;
	}
	
	
}
